<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>GL_CAR</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <t:base type="uploadify"></t:base>
  <script type="text/javascript">
  //编写自定义JS代码
  </script>
 </head>
 <body>
		<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="${action}" callback="jeecgFormFileCallBack@Override" tiptype="6">
					<input id="id" name="id" type="hidden" value="${glCarPage.id }"/>
		<table style="width: 99%;" cellpadding="0" cellspacing="1" class="formtable">
					<tr>
						<td align="right">
							<label class="Validform_label">
								单位/个人名称:
							</label>
						</td>
						<td class="value" colspan="3">
						    <input id="fullname" name="fullname" type="text" maxlength="150" style="width: 90%"  ignore="ignore"  value='${glCarPage.fullname}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">单位全称</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								联系人:
							</label>
						</td>
						<td class="value">
						    <input id="contacter" name="contacter" type="text" maxlength="20" style="width: 150px"  ignore="ignore"  value='${glCarPage.contacter}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">联系人姓名</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								联系电话:
							</label>
						</td>
						<td class="value">
						    <input id="mobile" name="mobile" type="text" maxlength="50" style="width: 150px"  ignore="ignore"  value='${glCarPage.mobile}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">电话</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								长期流向:
							</label>
						</td>
						<td class="value">
						    <input id="direction" name="direction" type="text" maxlength="50" style="width: 150px"  ignore="ignore"  value='${glCarPage.direction}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">服务区域</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								车型:
							</label>
						</td>
						<td class="value">
						    <input id="truckcat" name="truckcat" type="text" maxlength="20" style="width: 150px"  ignore="ignore"  value='${glCarPage.truckcat}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">车型</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								车辆载重:
							</label>
						</td>
						<td class="value">
						    <input id="ratedload" name="ratedload" type="text" maxlength="50" style="width: 150px"  ignore="ignore"  value='${glCarPage.ratedload}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">载重</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								车辆数量:
							</label>
						</td>
						<td class="value">
						    <input id="trucknum" name="trucknum" type="text" maxlength="20" style="width: 150px"  ignore="ignore"  value='${glCarPage.trucknum}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">数量</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								有效期开始:
							</label>
						</td>
						<td class="value">
									  <input id="validstartdate" name="validstartdate" type="text" style="width: 150px"  class="Wdate" onClick="WdatePicker()"  datatype="*"  ignore="checked" value='<fmt:formatDate value='${glCarPage.validstartdate}' type="date" pattern="yyyy-MM-dd"/>'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">有效期开始</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								有效期结束:
							</label>
						</td>
						<td class="value">
									  <input id="validenddate" name="validenddate" type="text" style="width: 150px"  class="Wdate" onClick="WdatePicker()"  datatype="*"  ignore="checked" value='<fmt:formatDate value='${glCarPage.validenddate}' type="date" pattern="yyyy-MM-dd"/>'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">有效期结束</label>
						</td>
					</tr>
					<%-- <tr>
						<td align="right">
							<label class="Validform_label">
								申请人编号:
							</label>
						</td>
						<td class="value">
						    <input id="userid" name="userid" type="text" maxlength="19" style="width: 150px"  datatype="n"  ignore="ignore"  value='${glCarPage.userid}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">申请人编号</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								申请时间:
							</label>
						</td>
						<td class="value">
									  <input id="reqtime" name="reqtime" type="text" style="width: 150px"  class="Wdate" onClick="WdatePicker()"  ignore="ignore" value='<fmt:formatDate value='${glCarPage.reqtime}' type="date" pattern="yyyy-MM-dd"/>'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">申请时间</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								信息来源:
							</label>
						</td>
						<td class="value">
						    <t:dictSelect field="infosource" type="list"  typeGroupCode="REGSOURCE"   defaultVal="${glCarPage.infosource}" hasLabel="false"  title="信息来源" ></t:dictSelect>  
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">信息来源</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								申请状态:
							</label>
						</td>
						<td class="value">
							<t:dictSelect field="reqstate" type="list"  typeGroupCode="STANDARDVERIFYSTATUS"   defaultVal="${glCarPage.reqstate}" hasLabel="false"  title="申请状态" ></t:dictSelect>     
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">申请状态</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								驾驶员姓名:
							</label>
						</td>
						<td class="value">
						    <input id="truckname" name="truckname" type="text" maxlength="10" style="width: 150px"  ignore="ignore"  value='${glCarPage.truckname}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">驾驶员姓名</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								驾驶员资质信息:
							</label>
						</td>
						<td class="value">
		<table id="jsyzz_fileTable"></table>
		<div class="form jeecgDetail">
			<t:upload name="jsyzz" id="jsyzz" queueID="filediv_jsyzz" outhtml="false" uploader="cgUploadController.do?saveFiles"  extend="pic" buttonText='添加图片'  onUploadStart="jsyzzOnUploadStart"> </t:upload>
			<div class="form" id="filediv_jsyzz"></div>
			<script type="text/javascript">
				function jsyzzOnUploadStart(file){
					var cgFormId=$("input[name='id']").val();
					$('#jsyzz').uploadify("settings", "formData", {
						'cgFormId':cgFormId,
						'cgFormName':'gl_car',
						'cgFormField':'JSYZZ'
					});
				}
			</script>
		</div>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">驾驶员资质信息</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								车辆资质信息:
							</label>
						</td>
						<td class="value">
		<table id="clzz_fileTable"></table>
		<div class="form jeecgDetail">
			<t:upload name="clzz" id="clzz" queueID="filediv_clzz" outhtml="false" uploader="cgUploadController.do?saveFiles"  extend="pic" buttonText='添加图片'  onUploadStart="clzzOnUploadStart"> </t:upload>
			<div class="form" id="filediv_clzz"></div>
			<script type="text/javascript">
				function clzzOnUploadStart(file){
					var cgFormId=$("input[name='id']").val();
					$('#clzz').uploadify("settings", "formData", {
						'cgFormId':cgFormId,
						'cgFormName':'gl_car',
						'cgFormField':'CLZZ'
					});
				}
			</script>
		</div>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">车辆资质信息</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								驾驶证:
							</label>
						</td>
						<td class="value">
		<table id="jsz_fileTable"></table>
		<div class="form jeecgDetail">
			<t:upload name="jsz" id="jsz" queueID="filediv_jsz" outhtml="false" uploader="cgUploadController.do?saveFiles"  extend="pic" buttonText='添加图片'  onUploadStart="jszOnUploadStart"> </t:upload>
			<div class="form" id="filediv_jsz"></div>
			<script type="text/javascript">
				function jszOnUploadStart(file){
					var cgFormId=$("input[name='id']").val();
					$('#jsz').uploadify("settings", "formData", {
						'cgFormId':cgFormId,
						'cgFormName':'gl_car',
						'cgFormField':'JSZ'
					});
				}
			</script>
		</div>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">驾驶证</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								行车证:
							</label>
						</td>
						<td class="value">
		<table id="xcz_fileTable"></table>
		<div class="form jeecgDetail">
			<t:upload name="xcz" id="xcz" queueID="filediv_xcz" outhtml="false" uploader="cgUploadController.do?saveFiles"  extend="pic" buttonText='添加图片'  onUploadStart="xczOnUploadStart"> </t:upload>
			<div class="form" id="filediv_xcz"></div>
			<script type="text/javascript">
				function xczOnUploadStart(file){
					var cgFormId=$("input[name='id']").val();
					$('#xcz').uploadify("settings", "formData", {
						'cgFormId':cgFormId,
						'cgFormName':'gl_car',
						'cgFormField':'XCZ'
					});
				}
			</script>
		</div>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">行车证</label>
						</td>
					</tr> --%>
					<tr>
						<td align="right">
							<label class="Validform_label">
								备注:
							</label>
						</td>
						<td class="value" colspan="3">
						    <input id="remark" name="remark" type="text" maxlength="500" style="width: 90%"  ignore="ignore"  value='${glCarPage.remark}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">备注</label>
						</td>
					</tr>
				
				
				<table id="tabVerify" style="margin-top:10px;width: 99%;display:none;" cellpadding="0" cellspacing="1" class="formtable">
				<input id="verifyflag" name="verifyflag" type="hidden" value="false"/>
				<tr>
						<td align="right">
							<label class="Validform_label">
								审核意见:
							</label>
						</td>
						<td class="value">
						  	<textarea id="verifynote" name="verifynote" style="height:auto;width:570px;" rows="6" ignore="ignore" ></textarea>
						</td>
					</tr>
			</table>
				
				
			</table>
		</t:formvalid>
 </body>
	  	<script type="text/javascript">
		  	//加载 已存在的 文件
		  	$(function(){
	  			var cgFormId=$("input[name='id']").val();
		  		$.ajax({
		  		   type: "post",
		  		   url: "glCarController.do?getFiles&id=" +  cgFormId,
		  		   success: function(data){
		  			 var arrayFileObj = jQuery.parseJSON(data).obj;
		  			 
		  			$.each(arrayFileObj,function(n,file){
		  				var fieldName = file.field.toLowerCase();
		  				var table = $("#"+fieldName+"_fileTable");
		  				var tr = $("<tr style=\"height:34px;\"></tr>");
		  				var title = file.title;
		  				if(title.length > 15){
		  					title = title.substring(0,12) + "...";
		  				}
		  				var td_title = $("<td>" + title + "</td>");
		  		  		var td_download = $("<td><a style=\"margin-left:10px;\" href=\"commonController.do?viewFile&fileid=" + file.fileKey + "&subclassname=org.jeecgframework.web.cgform.entity.upload.CgUploadEntity\" title=\"下载\">下载</a></td>")
		  		  		var td_view = $("<td><a style=\"margin-left:10px;\" href=\"javascript:void(0);\" onclick=\"openwindow('预览','commonController.do?openViewFile&fileid=" + file.fileKey + "&subclassname=org.jeecgframework.web.cgform.entity.upload.CgUploadEntity','fList',700,500)\">预览</a></td>");
		  		  		tr.appendTo(table);
		  		  		td_title.appendTo(tr);
		  		  		td_download.appendTo(tr);
		  		  		td_view.appendTo(tr);
		  		  		if(location.href.indexOf("load=detail")==-1){
			  		  		var td_del = $("<td><a style=\"margin-left:10px;\" href=\"javascript:void(0)\" class=\"jeecgDetail\" onclick=\"del('cgUploadController.do?delFile&id=" + file.fileKey + "',this)\">删除</a></td>");
			  		  		td_del.appendTo(tr);
		  		  		}
		  			 });
		  		   }
		  		});
		  	});
		  	
		  	/**
		 	 * 删除图片数据资源
		 	 */
		  	function del(url,obj){
		  		var content = "请问是否要删除该资源";
		  		var navigatorName = "Microsoft Internet Explorer"; 
		  		if( navigator.appName == navigatorName ){ 
		  			$.dialog.confirm(content, function(){
		  				submit(url,obj);
		  			}, function(){
		  			});
		  		}else{
		  			layer.open({
						title:"提示",
						content:content,
						icon:7,
						yes:function(index){
							submit(url,obj);
						},
						btn:['确定','取消'],
						btn2:function(index){
							layer.close(index);
						}
					});
		  		}
		  	}
		  	
		  	function submit(url,obj){
		  		$.ajax({
		  			async : false,
		  			cache : false,
		  			type : 'POST',
		  			url : url,// 请求的action路径
		  			error : function() {// 请求失败处理函数
		  			},
		  			success : function(data) {
		  				var d = $.parseJSON(data);
		  				if (d.success) {
		  					var msg = d.msg;
		  					tip(msg);
		  					obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode);
		  				} else {
		  					tip(d.msg);
		  				}
		  			}
		  		});
		  	}
		  	
	  		function jeecgFormFileCallBack(data){
	  			if (data.success == true) {
					uploadFile(data);
				} else {
					if (data.responseText == '' || data.responseText == undefined) {
						$.messager.alert('错误', data.msg);
						$.Hidemsg();
					} else {
						try {
							var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
							$.messager.alert('错误', emsg);
							$.Hidemsg();
						} catch(ex) {
							$.messager.alert('错误', data.responseText + '');
						}
					}
					return false;
				}
				if (!neibuClickFlag) {
					var win = frameElement.api.opener;
					win.reloadTable();
				}
	  		}
	  		function upload() {
					$('#jsyzz').uploadify('upload', '*');	
					$('#clzz').uploadify('upload', '*');	
					$('#jsz').uploadify('upload', '*');	
					$('#xcz').uploadify('upload', '*');	
			}
			
			var neibuClickFlag = false;
			function neibuClick() {
				neibuClickFlag = true; 
				$('#btn_sub').trigger('click');
			}
			function cancel() {
					$('#jsyzz').uploadify('cancel', '*');	
					$('#clzz').uploadify('cancel', '*');	
					$('#jsz').uploadify('cancel', '*');	
					$('#xcz').uploadify('cancel', '*');	
			}
			function uploadFile(data){
				if(!$("input[name='id']").val()){
					if(data.obj!=null && data.obj!='undefined'){
						$("input[name='id']").val(data.obj.id);
					}
				}
				if($(".uploadify-queue-item").length>0){
					upload();
				}else{
					if (neibuClickFlag){
						alert(data.msg);
						neibuClickFlag = false;
					}else {
						var win = frameElement.api.opener;
						win.reloadTable();
						win.tip(data.msg);
						frameElement.api.close();
					}
				}
			}
	  	</script>
